<template>
  <div class="app-container">
    <!-- 对话框(添加 / 修改) -->
    <el-dialog :title="dialogTitle" :visible.sync="dialogVisible" width="45%" v-dialogDrag append-to-body>
      <el-form ref="formRef" :model="formData" :rules="formRules" v-loading="formLoading" label-width="100px">
                    <el-form-item label="证券代码" prop="seccode">
                      <el-input v-model="formData.seccode" placeholder="请输入证券代码" />
                    </el-form-item>
                    <el-form-item label="证券简称" prop="secname">
                      <el-input v-model="formData.secname" placeholder="请输入证券简称" />
                    </el-form-item>
                    <el-form-item label="机构名称" prop="orgname">
                      <el-input v-model="formData.orgname" placeholder="请输入机构名称" />
                    </el-form-item>
                    <el-form-item label="公告日期" prop="declaredate">
                      <el-date-picker clearable v-model="formData.declaredate" type="date" value-format="timestamp" placeholder="选择公告日期" />
                    </el-form-item>
                    <el-form-item label="开始日期" prop="startdate">
                      <el-date-picker clearable v-model="formData.startdate" type="date" value-format="timestamp" placeholder="选择开始日期" />
                    </el-form-item>
                    <el-form-item label="截止日期" prop="enddate">
                      <el-date-picker clearable v-model="formData.enddate" type="date" value-format="timestamp" placeholder="选择截止日期" />
                    </el-form-item>
                    <el-form-item label="报告年度" prop="f001d">
                      <el-input v-model="formData.f001d" placeholder="请输入报告年度" />
                    </el-form-item>
                    <el-form-item label="合并类型编码" prop="f002v">
                      <el-input v-model="formData.f002v" placeholder="请输入合并类型编码" />
                    </el-form-item>
                    <el-form-item label="合并类型" prop="f003v">
                      <el-input v-model="formData.f003v" placeholder="请输入合并类型" />
                    </el-form-item>
                    <el-form-item label="报表来源编码" prop="f004v">
                      <el-input v-model="formData.f004v" placeholder="请输入报表来源编码" />
                    </el-form-item>
                    <el-form-item label="报表来源" prop="f005v">
                      <el-input v-model="formData.f005v" placeholder="请输入报表来源" />
                    </el-form-item>
                    <el-form-item label="营业总收入	单位：元" prop="f035n">
                      <el-input v-model="formData.f035n" placeholder="请输入营业总收入	单位：元" />
                    </el-form-item>
                    <el-form-item label="其中：营业收入	单位：元" prop="f006n">
                      <el-input v-model="formData.f006n" placeholder="请输入其中：营业收入	单位：元" />
                    </el-form-item>
                    <el-form-item label="利息收入-营业总收入	单位：元" prop="f033n">
                      <el-input v-model="formData.f033n" placeholder="请输入利息收入-营业总收入	单位：元" />
                    </el-form-item>
                    <el-form-item label="已赚保费	单位：元" prop="f034n">
                      <el-input v-model="formData.f034n" placeholder="请输入已赚保费	单位：元" />
                    </el-form-item>
                    <el-form-item label="手续费及佣金收入	单位：元" prop="f042n">
                      <el-input v-model="formData.f042n" placeholder="请输入手续费及佣金收入	单位：元" />
                    </el-form-item>
                    <el-form-item label="营业总成本	单位：元" prop="f036n">
                      <el-input v-model="formData.f036n" placeholder="请输入营业总成本	单位：元" />
                    </el-form-item>
                    <el-form-item label="其中：营业成本	单位：元" prop="f007n">
                      <el-input v-model="formData.f007n" placeholder="请输入其中：营业成本	单位：元" />
                    </el-form-item>
                    <el-form-item label="利息支出	单位：元" prop="f043n">
                      <el-input v-model="formData.f043n" placeholder="请输入利息支出	单位：元" />
                    </el-form-item>
                    <el-form-item label="手续费及佣金支出	单位：元" prop="f044n">
                      <el-input v-model="formData.f044n" placeholder="请输入手续费及佣金支出	单位：元" />
                    </el-form-item>
                    <el-form-item label="退保金	单位：元" prop="f045n">
                      <el-input v-model="formData.f045n" placeholder="请输入退保金	单位：元" />
                    </el-form-item>
                    <el-form-item label="赔付支出净额	单位：元" prop="f046n">
                      <el-input v-model="formData.f046n" placeholder="请输入赔付支出净额	单位：元" />
                    </el-form-item>
                    <el-form-item label="提取保险责任准备金净额	单位：元" prop="f047n">
                      <el-input v-model="formData.f047n" placeholder="请输入提取保险责任准备金净额	单位：元" />
                    </el-form-item>
                    <el-form-item label="保单红利支出	单位：元" prop="f048n">
                      <el-input v-model="formData.f048n" placeholder="请输入保单红利支出	单位：元" />
                    </el-form-item>
                    <el-form-item label="分保费用	单位：元" prop="f049n">
                      <el-input v-model="formData.f049n" placeholder="请输入分保费用	单位：元" />
                    </el-form-item>
                    <el-form-item label="营业税金及附加	单位：元" prop="f008n">
                      <el-input v-model="formData.f008n" placeholder="请输入营业税金及附加	单位：元" />
                    </el-form-item>
                    <el-form-item label="销售费用	单位：元" prop="f009n">
                      <el-input v-model="formData.f009n" placeholder="请输入销售费用	单位：元" />
                    </el-form-item>
                    <el-form-item label="管理费用	单位：元" prop="f010n">
                      <el-input v-model="formData.f010n" placeholder="请输入管理费用	单位：元" />
                    </el-form-item>
                    <el-form-item label="勘探费用	单位：元" prop="f011n">
                      <el-input v-model="formData.f011n" placeholder="请输入勘探费用	单位：元" />
                    </el-form-item>
                    <el-form-item label="财务费用	单位：元" prop="f012n">
                      <el-input v-model="formData.f012n" placeholder="请输入财务费用	单位：元" />
                    </el-form-item>
                    <el-form-item label="研发费用" prop="f056n">
                      <el-input v-model="formData.f056n" placeholder="请输入研发费用" />
                    </el-form-item>
                    <el-form-item label="资产减值损失-营业总成本	单位：元" prop="f013n">
                      <el-input v-model="formData.f013n" placeholder="请输入资产减值损失-营业总成本	单位：元" />
                    </el-form-item>
                    <el-form-item label="加：公允价值变动净收益	单位：元" prop="f014n">
                      <el-input v-model="formData.f014n" placeholder="请输入加：公允价值变动净收益	单位：元" />
                    </el-form-item>
                    <el-form-item label="投资收益	单位：元" prop="f015n">
                      <el-input v-model="formData.f015n" placeholder="请输入投资收益	单位：元" />
                    </el-form-item>
                    <el-form-item label="其中：对联营企业和合营企业的投资收益	单位：元" prop="f016n">
                      <el-input v-model="formData.f016n" placeholder="请输入其中：对联营企业和合营企业的投资收益	单位：元" />
                    </el-form-item>
                    <el-form-item label="汇兑收益	单位：元" prop="f037n">
                      <el-input v-model="formData.f037n" placeholder="请输入汇兑收益	单位：元" />
                    </el-form-item>
                    <el-form-item label="其它收入" prop="f051n">
                      <el-input v-model="formData.f051n" placeholder="请输入其它收入" />
                    </el-form-item>
                    <el-form-item label="信用减值损失-营业总成本" prop="f057n">
                      <el-input v-model="formData.f057n" placeholder="请输入信用减值损失-营业总成本" />
                    </el-form-item>
                    <el-form-item label="净敞口套期收益" prop="f058n">
                      <el-input v-model="formData.f058n" placeholder="请输入净敞口套期收益" />
                    </el-form-item>
                    <el-form-item label="资产处置收益" prop="f059n">
                      <el-input v-model="formData.f059n" placeholder="请输入资产处置收益" />
                    </el-form-item>
                    <el-form-item label="影响营业利润的其他科目	单位：元" prop="f017n">
                      <el-input v-model="formData.f017n" placeholder="请输入影响营业利润的其他科目	单位：元" />
                    </el-form-item>
                    <el-form-item label="营业利润	单位：元" prop="f018n">
                      <el-input v-model="formData.f018n" placeholder="请输入营业利润	单位：元" />
                    </el-form-item>
                    <el-form-item label="加：补贴收入	单位：元" prop="f019n">
                      <el-input v-model="formData.f019n" placeholder="请输入加：补贴收入	单位：元" />
                    </el-form-item>
                    <el-form-item label="营业外收入	单位：元" prop="f020n">
                      <el-input v-model="formData.f020n" placeholder="请输入营业外收入	单位：元" />
                    </el-form-item>
                    <el-form-item label="其中：非流动资产处置利得	单位：元" prop="f050n">
                      <el-input v-model="formData.f050n" placeholder="请输入其中：非流动资产处置利得	单位：元" />
                    </el-form-item>
                    <el-form-item label="减：营业外支出	单位：元" prop="f021n">
                      <el-input v-model="formData.f021n" placeholder="请输入减：营业外支出	单位：元" />
                    </el-form-item>
                    <el-form-item label="其中：非流动资产处置损失	单位：元" prop="f022n">
                      <el-input v-model="formData.f022n" placeholder="请输入其中：非流动资产处置损失	单位：元" />
                    </el-form-item>
                    <el-form-item label="加：影响利润总额的其他科目	单位：元" prop="f023n">
                      <el-input v-model="formData.f023n" placeholder="请输入加：影响利润总额的其他科目	单位：元" />
                    </el-form-item>
                    <el-form-item label="利润总额	单位：元" prop="f024n">
                      <el-input v-model="formData.f024n" placeholder="请输入利润总额	单位：元" />
                    </el-form-item>
                    <el-form-item label="减：所得税	单位：元" prop="f025n">
                      <el-input v-model="formData.f025n" placeholder="请输入减：所得税	单位：元" />
                    </el-form-item>
                    <el-form-item label="加：影响净利润的其他科目	单位：元" prop="f026n">
                      <el-input v-model="formData.f026n" placeholder="请输入加：影响净利润的其他科目	单位：元" />
                    </el-form-item>
                    <el-form-item label="净利润	单位：元" prop="f027n">
                      <el-input v-model="formData.f027n" placeholder="请输入净利润	单位：元" />
                    </el-form-item>
                    <el-form-item label="持续经营净利润" prop="f060n">
                      <el-input v-model="formData.f060n" placeholder="请输入持续经营净利润" />
                    </el-form-item>
                    <el-form-item label="终止经营净利润" prop="f061n">
                      <el-input v-model="formData.f061n" placeholder="请输入终止经营净利润" />
                    </el-form-item>
                    <el-form-item label="归属于母公司所有者的净利润	单位：元" prop="f028n">
                      <el-input v-model="formData.f028n" placeholder="请输入归属于母公司所有者的净利润	单位：元" />
                    </el-form-item>
                    <el-form-item label="少数股东损益	单位：元" prop="f029n">
                      <el-input v-model="formData.f029n" placeholder="请输入少数股东损益	单位：元" />
                    </el-form-item>
                    <el-form-item label="基本每股收益" prop="f031n">
                      <el-input v-model="formData.f031n" placeholder="请输入基本每股收益" />
                    </el-form-item>
                    <el-form-item label="稀释每股收益" prop="f032n">
                      <el-input v-model="formData.f032n" placeholder="请输入稀释每股收益" />
                    </el-form-item>
                    <el-form-item label="其他综合收益的税后净额	单位：元" prop="f038n">
                      <el-input v-model="formData.f038n" placeholder="请输入其他综合收益的税后净额	单位：元" />
                    </el-form-item>
                    <el-form-item label="综合收益总额	单位：元" prop="f039n">
                      <el-input v-model="formData.f039n" placeholder="请输入综合收益总额	单位：元" />
                    </el-form-item>
                    <el-form-item label="其中：归属于母公司	单位：元" prop="f040n">
                      <el-input v-model="formData.f040n" placeholder="请输入其中：归属于母公司	单位：元" />
                    </el-form-item>
                    <el-form-item label="其中：归属于少数股东	单位：元" prop="f041n">
                      <el-input v-model="formData.f041n" placeholder="请输入其中：归属于少数股东	单位：元" />
                    </el-form-item>
                    <el-form-item label="备注" prop="memo">
                      <el-input v-model="formData.memo" placeholder="请输入备注" />
                    </el-form-item>
                    <el-form-item label="其中：利息费用	2019-03-15新增" prop="f062n">
                      <el-input v-model="formData.f062n" placeholder="请输入其中：利息费用	2019-03-15新增" />
                    </el-form-item>
                    <el-form-item label="其中：利息收入	2019-03-15新增" prop="f063n">
                      <el-input v-model="formData.f063n" placeholder="请输入其中：利息收入	2019-03-15新增" />
                    </el-form-item>
                    <el-form-item label="信用减值损失（2019格式）" prop="f064n">
                      <el-input v-model="formData.f064n" placeholder="请输入信用减值损失（2019格式）" />
                    </el-form-item>
                    <el-form-item label="资产减值损失（2019格式）" prop="f065n">
                      <el-input v-model="formData.f065n" placeholder="请输入资产减值损失（2019格式）" />
                    </el-form-item>
                    <el-form-item label="其中：归属母公司所有者的其他综合收益的税后净额" prop="f066n">
                      <el-input v-model="formData.f066n" placeholder="请输入其中：归属母公司所有者的其他综合收益的税后净额" />
                    </el-form-item>
                    <el-form-item label="其中：归属于少数股东的其他综合收益的税后净额" prop="f067n">
                      <el-input v-model="formData.f067n" placeholder="请输入其中：归属于少数股东的其他综合收益的税后净额" />
                    </el-form-item>
                    <el-form-item label="以摊余成本计量的金融资产终止确认收益	2024年02新增" prop="f030n">
                      <el-input v-model="formData.f030n" placeholder="请输入以摊余成本计量的金融资产终止确认收益	2024年02新增" />
                    </el-form-item>
                    <el-form-item label="影响营业总收入的其他科目	2024年02新增" prop="f072n">
                      <el-input v-model="formData.f072n" placeholder="请输入影响营业总收入的其他科目	2024年02新增" />
                    </el-form-item>
                    <el-form-item label="影响营业总成本的其他科目	2024年02新增" prop="f073n">
                      <el-input v-model="formData.f073n" placeholder="请输入影响营业总成本的其他科目	2024年02新增" />
                    </el-form-item>
      </el-form>
              <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm" :disabled="formLoading">确 定</el-button>
        <el-button @click="dialogVisible = false">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  import * as LrBaseApi from '@/api/invest/lrbase';
      export default {
    name: "LrBaseForm",
    components: {
                    },
    data() {
      return {
        // 弹出层标题
        dialogTitle: "",
        // 是否显示弹出层
        dialogVisible: false,
        // 表单的加载中：1）修改时的数据加载；2）提交的按钮禁用
        formLoading: false,
        // 表单参数
        formData: {
                            id: undefined,
                            seccode: undefined,
                            secname: undefined,
                            orgname: undefined,
                            declaredate: undefined,
                            startdate: undefined,
                            enddate: undefined,
                            f001d: undefined,
                            f002v: undefined,
                            f003v: undefined,
                            f004v: undefined,
                            f005v: undefined,
                            f035n: undefined,
                            f006n: undefined,
                            f033n: undefined,
                            f034n: undefined,
                            f042n: undefined,
                            f036n: undefined,
                            f007n: undefined,
                            f043n: undefined,
                            f044n: undefined,
                            f045n: undefined,
                            f046n: undefined,
                            f047n: undefined,
                            f048n: undefined,
                            f049n: undefined,
                            f008n: undefined,
                            f009n: undefined,
                            f010n: undefined,
                            f011n: undefined,
                            f012n: undefined,
                            f056n: undefined,
                            f013n: undefined,
                            f014n: undefined,
                            f015n: undefined,
                            f016n: undefined,
                            f037n: undefined,
                            f051n: undefined,
                            f057n: undefined,
                            f058n: undefined,
                            f059n: undefined,
                            f017n: undefined,
                            f018n: undefined,
                            f019n: undefined,
                            f020n: undefined,
                            f050n: undefined,
                            f021n: undefined,
                            f022n: undefined,
                            f023n: undefined,
                            f024n: undefined,
                            f025n: undefined,
                            f026n: undefined,
                            f027n: undefined,
                            f060n: undefined,
                            f061n: undefined,
                            f028n: undefined,
                            f029n: undefined,
                            f031n: undefined,
                            f032n: undefined,
                            f038n: undefined,
                            f039n: undefined,
                            f040n: undefined,
                            f041n: undefined,
                            memo: undefined,
                            f062n: undefined,
                            f063n: undefined,
                            f064n: undefined,
                            f065n: undefined,
                            f066n: undefined,
                            f067n: undefined,
                            f030n: undefined,
                            f072n: undefined,
                            f073n: undefined,
        },
        // 表单校验
        formRules: {
        },
                        };
    },
    methods: {
      /** 打开弹窗 */
     async open(id) {
        this.dialogVisible = true;
        this.reset();
        // 修改时，设置数据
        if (id) {
          this.formLoading = true;
          try {
            const res = await LrBaseApi.getLrBase(id);
            this.formData = res.data;
            this.title = "修改个股报告期利润";
          } finally {
            this.formLoading = false;
          }
        }
        this.title = "新增个股报告期利润";
              },
      /** 提交按钮 */
      async submitForm() {
        // 校验主表
        await this.$refs["formRef"].validate();
                  this.formLoading = true;
        try {
          const data = this.formData;
                  // 修改的提交
          if (data.id) {
            await LrBaseApi.updateLrBase(data);
            this.$modal.msgSuccess("修改成功");
            this.dialogVisible = false;
            this.$emit('success');
            return;
          }
          // 添加的提交
          await LrBaseApi.createLrBase(data);
          this.$modal.msgSuccess("新增成功");
          this.dialogVisible = false;
          this.$emit('success');
        } finally {
          this.formLoading = false;
        }
      },
                      /** 表单重置 */
      reset() {
        this.formData = {
                            id: undefined,
                            seccode: undefined,
                            secname: undefined,
                            orgname: undefined,
                            declaredate: undefined,
                            startdate: undefined,
                            enddate: undefined,
                            f001d: undefined,
                            f002v: undefined,
                            f003v: undefined,
                            f004v: undefined,
                            f005v: undefined,
                            f035n: undefined,
                            f006n: undefined,
                            f033n: undefined,
                            f034n: undefined,
                            f042n: undefined,
                            f036n: undefined,
                            f007n: undefined,
                            f043n: undefined,
                            f044n: undefined,
                            f045n: undefined,
                            f046n: undefined,
                            f047n: undefined,
                            f048n: undefined,
                            f049n: undefined,
                            f008n: undefined,
                            f009n: undefined,
                            f010n: undefined,
                            f011n: undefined,
                            f012n: undefined,
                            f056n: undefined,
                            f013n: undefined,
                            f014n: undefined,
                            f015n: undefined,
                            f016n: undefined,
                            f037n: undefined,
                            f051n: undefined,
                            f057n: undefined,
                            f058n: undefined,
                            f059n: undefined,
                            f017n: undefined,
                            f018n: undefined,
                            f019n: undefined,
                            f020n: undefined,
                            f050n: undefined,
                            f021n: undefined,
                            f022n: undefined,
                            f023n: undefined,
                            f024n: undefined,
                            f025n: undefined,
                            f026n: undefined,
                            f027n: undefined,
                            f060n: undefined,
                            f061n: undefined,
                            f028n: undefined,
                            f029n: undefined,
                            f031n: undefined,
                            f032n: undefined,
                            f038n: undefined,
                            f039n: undefined,
                            f040n: undefined,
                            f041n: undefined,
                            memo: undefined,
                            f062n: undefined,
                            f063n: undefined,
                            f064n: undefined,
                            f065n: undefined,
                            f066n: undefined,
                            f067n: undefined,
                            f030n: undefined,
                            f072n: undefined,
                            f073n: undefined,
        };
        this.resetForm("formRef");
      }
    }
  };
</script>